﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.intellitack.layar.library;


namespace com.intellitack.layar.sample
{
    public class SampleLayar:AbstractLayerApplication
    {
        public override LayarResponse processLayarRequest(LayarRequest request)
        {
            //Create a placeholder sample response
            LayarResponse response = createSampleResponse();
            //Create a placeholder sample POI
            PointOfInterest poi = createSamplePOI(request);
            //Add POI to response hotspots
            response.hotspots.Add(poi);

            //For KML testing
            //foreach (PointOfInterest poiKML in createSamplePOIsFromKML(request))
            //    response.hotspots.Add(poiKML);

            //Return the Response
            return response;

        }

        protected LayarResponse createSampleResponse() 
        {
            //Create a sample response.
            LayarResponse response = new LayarResponse();
            response.layer = "Sample Layar";                //Set Title
            response.morePages = false;                     //Set More Pages, this is used when you want to paginate your POIs
            //Return the response
            return response;
        }

        protected IEnumerable<PointOfInterest> createSamplePOIsFromKML(LayarRequest request)
        {
            return KMLHelper.GetGeoList(request, @"D:\Websites\layardotnet\LayarLibrary_1.0\GetPOIService\App_Data\locations.kml");
        }

        protected PointOfInterest createSamplePOI(LayarRequest request) 
        {
            //Build a sample POI, based on request location.
            PointOfInterest poi = new PointOfInterest();
            poi.distance = 0;
            poi.attribution = "CodePlex Layar HttpHandler Sample";
            poi.title = "Single Sample POI";
            poi.lat = request.lat;
            poi.lon = request.lon;
            poi.line2 = "Time " + DateTime.Now;
            poi.line3 = String.Empty;
            poi.line4 = String.Empty;
            poi.type = 0;
            poi.id = "Sample POI";

            return poi;
        }
    }
}
